#include "plane.h"

Plane::Plane(d_Vec3f n, float dd, Material *mat)
{
	normal = n;
	material = mat;
	d = dd;
}

bool Plane::intersect(const Ray &r, Hit &h, float tmin)
{
	float t = (d-dot(r.getOrigin(), normal))/dot(r.getDirection(),normal);

	if(t>=tmin&&t<h.getT())
	{
		h.set(t, material, normal);
		return true;
	}

	return false;

}
bool Plane::inside(d_Vec3f point)
{
	if(dot(point,normal)>d)
		return true;
	return false;
}
